/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.yonsei.iwb.sdt.refinement;

import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

/**
 *
 * @author JDK
 */
public class ConstraintConstructor extends Hashtable<Integer, String>{

    private int refinementType;
    private int constraintType;
    
    public static final int NEGATIONPREFIX = 0;
    public static final int EQUALITYPREFIX = 1;
    public static final int BASERESOURCE = 2;
    public static final int MATERESOURCE = 3;
    public static final int BASEPROPERTY = 4;
    public static final int BASEINTEGER = 5;
    public static final int BASESTRING = 6;
    public static final int BASEBOOLEAN = 7;
    public static final int MULTIDECOMSECASE = 8;
    public static final int CONDISPREFIX = 9;
    
    public ConstraintConstructor(ConstraintConstructor cc){
        Enumeration<Integer> e = cc.keys();        
        while(e.hasMoreElements()){
            int key = e.nextElement();
            String s = cc.get(key);
            this.put(key, s);
        }
    }

    public ConstraintConstructor(Resource r){
        //concept and qualification
        this.refinementType = RefinementType.CONCEPTCONSTRUCTOR;
        this.constraintType = ConstraintConstructor.BASERESOURCE;
        this.put(BASERESOURCE, r.getLocalName());
        
    }
    
    public ConstraintConstructor(String multiDecomposeSet){
        this.constraintType = ConstraintConstructor.MULTIDECOMSECASE;
        this.put(MULTIDECOMSECASE, multiDecomposeSet);
    }
    
    public ConstraintConstructor(String prefix, int base, Property p){
        //cardinality int datatype domain restriction
        this.refinementType = RefinementType.DOMAINRESTRICTION;
        this.constraintType = ConstraintConstructor.BASEINTEGER;
        this.put(EQUALITYPREFIX, prefix);
        this.put(BASEINTEGER, ""+base);
        this.put(BASEPROPERTY, p.getLocalName());
        
    }
    
    public ConstraintConstructor(String prefix, String base, Property p){
        //cardinality String datatype domain restriction
        this.refinementType = RefinementType.DOMAINRESTRICTION;        
        this.constraintType = ConstraintConstructor.BASESTRING;
        this.put(EQUALITYPREFIX, prefix);
        this.put(BASESTRING, base);
        this.put(BASEPROPERTY, p.getLocalName());
    }
    
    
//    public ConstraintConstructor(String value, Property p){
//        //string type domain restriction
//        
//    }

//    public ConstraintConstructor(boolean value, Property p){
//        //boolean type domain restriction
//        
//    }
    
    public ConstraintConstructor(Resource base, String prefix, Resource mate){
        //conjunction and disjunction
//        this.refinementType = RefinementType.
        this.put(BASERESOURCE, base.getLocalName());
        this.put(MATERESOURCE, mate.getLocalName());
        this.put(CONDISPREFIX, prefix);                
    }
    
    
    
//    public ConstraintConstructor(Resource base, String prefix, Resource mate){
//        //conjunction
//    }
    
//    public String getRefinementName(){
////        return this.constraint_name;
//    }

    public int getRefinementType() {
        return refinementType;
    }

    public int getConstraintType() {
        return constraintType;
    }
    
}
